#include "iostream"
#include "cstring"

using namespace std;

int main() {
    char s[110], t[110];
    while (cin >> t >> s)
    {
        int tn = strlen(t), sn = strlen(s);
        int l1 = 0, l2 = 0, cur_i, cur_j;

        int j = 0, max1 = 0;
        while (j < sn) {
            cur_i = 0, cur_j = j;
            while (t[cur_i] + s[cur_j] - '0' - '0' < 4 && cur_i < tn && cur_j < sn) {
                l1 = l1 + 1;
                if (cur_i + 1 < tn && cur_j + 1 < sn && t[cur_i + 1] + s[cur_j + 1] - '0' - '0' > 3) {
                    l1 = 0;
                    break;
                }
                cur_i = cur_i + 1;
                cur_j = cur_j + 1;
            }
            max1 = max1 > l1 ? max1 : l1;
            l1 = 0;
            j = j + 1;
        }

        j = 0;
        int max2 = 0;
        while (j < tn) {
            cur_i = 0, cur_j = j;
            while (s[cur_i] + t[cur_j] - '0' - '0' < 4 && cur_i < sn && cur_j < tn) {
                l2 = l2 + 1;
                if (cur_i + 1 < sn && cur_j + 1 < tn && s[cur_i + 1] + t[cur_j + 1] - '0' - '0' > 3) {
                    l2 = 0;
                    break;
                }
                cur_i = cur_i + 1;
                cur_j = cur_j + 1;
            }
            max2 = max2 > l2 ? max2 : l2;
            l2 = 0;
            j = j + 1;
        }

        int res = max1 > max2 ? max1 : max2;
        cout << tn + sn - res << '\n';
    }
    return 0;
}